package com.itheima.tlias84.controller;

import com.itheima.tlias84.dto.SelectStudentsDTO;
import com.itheima.tlias84.po.InsertStudetsParam;
import com.itheima.tlias84.po.SelectStudentPageParam;
import com.itheima.tlias84.servrce.StudentsService;
import com.itheima.tlias84.utils.ResultUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

@Slf4j
@RestController
@RequestMapping("students")
public class StudentsController {
    @Resource
    StudentsService studentService;

 @PostMapping
  public ResultUtil insertStudents (@RequestBody InsertStudetsParam Param){
     int i = studentService.insertStudents(Param);
     return ResultUtil.success(i);
 }
    @GetMapping
    public ResultUtil selelectStudentsPageParam(SelectStudentPageParam Param){
        if(Objects.isNull(Param.getPage())||Objects.isNull(Param.getPageSize())){
            return ResultUtil.fail("页面为空");
        }
        ResultUtil resultUtil = studentService.selelectStudentsPageParam(Param);
        return resultUtil;
    }
}
